<template>
	<view class="account-container">
		<view class="section">
			<view class="section-title">个人信息</view>
			<view class="info-list">
				<view class="info-item">
					<text class="label">头像</text>
					<view class="value-wrapper">
						<image class="avatar" src="/static/avatar-default.png" mode="aspectFill"></image>
						<text class="change-text">更换</text>
					</view>
				</view>
				<view class="info-item">
					<text class="label">昵称</text>
					<view class="value-wrapper">
						<text class="value">{{userInfo.nickname}}</text>
						<uni-icons type="right" size="16" color="#999"></uni-icons>
					</view>
				</view>
				<view class="info-item">
					<text class="label">手机号</text>
					<view class="value-wrapper">
						<text class="value">{{userInfo.phone}}</text>
						<uni-icons type="right" size="16" color="#999"></uni-icons>
					</view>
				</view>
				<view class="info-item">
					<text class="label">邮箱</text>
					<view class="value-wrapper">
						<text class="value">{{userInfo.email}}</text>
						<uni-icons type="right" size="16" color="#999"></uni-icons>
					</view>
				</view>
			</view>
		</view>

		<view class="section">
			<view class="section-title">安全设置</view>
			<view class="info-list">
				<view class="info-item" @click="handleChangePassword">
					<text class="label">修改密码</text>
					<view class="value-wrapper">
						<text class="value">定期更换密码更安全</text>
						<uni-icons type="right" size="16" color="#999"></uni-icons>
					</view>
				</view>
				<view class="info-item" @click="handleBindPhone">
					<text class="label">手机绑定</text>
					<view class="value-wrapper">
						<text class="value">{{userInfo.phone ? '已绑定' : '未绑定'}}</text>
						<uni-icons type="right" size="16" color="#999"></uni-icons>
					</view>
				</view>
				<view class="info-item" @click="handleLoginDevices">
					<text class="label">登录设备管理</text>
					<view class="value-wrapper">
						<text class="value">查看并管理已登录设备</text>
						<uni-icons type="right" size="16" color="#999"></uni-icons>
					</view>
				</view>
			</view>
		</view>

		<view class="section">
			<view class="section-title">账号安全</view>
			<view class="info-list">
				<view class="info-item" @click="handlePrivacySettings">
					<text class="label">隐私设置</text>
					<view class="value-wrapper">
						<text class="value">管理您的隐私信息</text>
						<uni-icons type="right" size="16" color="#999"></uni-icons>
					</view>
				</view>
				<view class="info-item" @click="handleAccountDelete">
					<text class="label">注销账号</text>
					<view class="value-wrapper">
						<text class="value">永久删除账号及相关数据</text>
						<uni-icons type="right" size="16" color="#999"></uni-icons>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			userInfo: {
				nickname: '用户名',
				phone: '138****8888',
				email: 'user@example.com'
			}
		}
	},
	methods: {
		handleChangePassword() {
			uni.navigateTo({
				url: '/pages/account/change-password'
			})
		},
		handleBindPhone() {
			uni.navigateTo({
				url: '/pages/account/bind-phone'
			})
		},
		handleLoginDevices() {
			uni.navigateTo({
				url: '/pages/account/login-devices'
			})
		},
		handlePrivacySettings() {
			uni.navigateTo({
				url: '/pages/account/privacy-settings'
			})
		},
		handleAccountDelete() {
			uni.showModal({
				title: '注销确认',
				content: '注销账号后，所有数据将被永久删除且无法恢复。确定要继续吗？',
				confirmColor: '#ff4d4f',
				success: (res) => {
					if (res.confirm) {
						// 执行注销操作
						uni.showToast({
							title: '账号已注销',
							icon: 'success'
						})
					}
				}
			})
		}
	}
}
</script>

<style lang="scss">
.account-container {
	min-height: 100vh;
	background: #f6f7f9;
	padding: 20rpx;
	
	.section {
		background: #ffffff;
		border-radius: 24rpx;
		margin-bottom: 20rpx;
		padding: 20rpx;
		
		.section-title {
			font-size: 32rpx;
			font-weight: 600;
			color: #333;
			margin-bottom: 20rpx;
			padding: 0 20rpx;
		}
		
		.info-list {
			.info-item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 30rpx 20rpx;
				border-bottom: 2rpx solid #f5f5f5;
				
				&:last-child {
					border-bottom: none;
				}
				
				.label {
					font-size: 28rpx;
					color: #333;
				}
				
				.value-wrapper {
					display: flex;
					align-items: center;
					
					.avatar {
						width: 80rpx;
						height: 80rpx;
						border-radius: 40rpx;
						margin-right: 10rpx;
					}
					
					.change-text {
						font-size: 24rpx;
						color: #007AFF;
					}
					
					.value {
						font-size: 28rpx;
						color: #666;
						margin-right: 10rpx;
					}
				}
			}
		}
	}
}
</style> 